package com.atguigu.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/a/*")
public class ServletA extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //创建cookie

        Cookie cookiea = new Cookie("keya", "valuea");
        Cookie cookieb = new Cookie("keyb", "valueb");

        //设置cookie的过期时间
        cookiea.setMaxAge(3600);

        //把cookie放入resp对象
        resp.addCookie(cookiea);
        resp.addCookie(cookieb);
    }
}
